package com.luxk.db.data.undo;

public class UndoAddress {
	
	private static final int NULL_DBA = 0;
	private static final int NULL_ROWNO = 0;
	
	private static final int MAX_DBA = Integer.MAX_VALUE;
	private static final int MAX_ROWNO = Short.MAX_VALUE;
	
	public int dba;
	public int rowNo; // 0~65535
	
	public UndoAddress(int dba, int rowNo) throws Exception {
		if (rowNo > Short.MAX_VALUE)
			throw new Exception("Undo address rowNo is invalid(" + rowNo + ")");
		
		this.dba = dba;
		this.rowNo = rowNo;
	}

	public boolean equals(UndoAddress ua) {
		return (this.dba == ua.dba && this.rowNo == ua.rowNo);
	}
	
	public boolean isNull(UndoAddress ua) {
		return (ua.dba == NULL_DBA && ua.rowNo == NULL_ROWNO);
	}
	
	public boolean isNull(int dba, int rowNo) {
		return (dba == NULL_DBA && rowNo == NULL_ROWNO);
	}
}
